﻿namespace BlazorAdmin.Generator.Models
{
    public class Column
    {
        /// <summary>
        /// 字段
        /// </summary>
        public string PropertyCode { get; set; }

        public string PropertyDesc { get; set; }

        public string PropertyType { get; set; }

        public EnumInputType InputType { get; set; }

        /// <summary>
        /// 字段长度
        /// </summary>
        public int Length { get; set; }

        /// <summary>
        /// 小数位数
        /// </summary>
        public int Point { get; set; }

        public bool IsNullable { get; set; }

        public bool IsKey { get; set; }

        public string GetNumFormat()
        {
            if (Point > 0)
            {
                var format = "#.";
                for (var i = 0; i < Point; i++)
                    format += "#";
                return $"FormatString=\"{format}\"";
            }
            else
            {
                return string.Empty;
            }
        }
    }
}
